<template>
  <div class="search-bar">
    <div class="select-bar">
      <div class="select-item">
        <label for="code-input">编码：</label>
        <input
          id="code-input"
          placeholder="输入编码"
          v-model="search1"
          class="input-field"
        />
      </div>

      <div class="select-item">
        <label for="name-input">名称：</label>
        <input
          id="name-input"
          placeholder="输入名称"
          v-model="search2"
          class="input-field"
        />
      </div>

      <el-button type="primary" @click="handleSearch" class="search-button">
        <i class="fas fa-search"></i>查询
      </el-button>
      <el-button type="default" @click="handleReset" class="reset-button">
        <i class="fas fa-undo"></i>重置
      </el-button>
      <el-button type="default" @click="toggleExpand" class="toggle-button">
        {{ isExpanded ? "收起" : "展开" }}
        <i
          class="fas"
          :class="isExpanded ? 'fa-angle-up' : 'fa-angle-down'"
        ></i>
      </el-button>
    </div>

    <!-- 展开/收起的内容 -->
    <div v-if="isExpanded" class="expand-content">
      <p>这里是展开的内容，可以放置任何您想要的信息。</p>
    </div>
    <h2>jdhfgsdilufhgosdiugfhsdfoiughdofiugbhdolfiugbn</h2>
  </div>
</template>

<script>
import { Button } from "element-ui";

export default {
  components: {
    "el-button": Button,
  },
  data() {
    return {
      search1: "", // 用于存储编码
      search2: "", // 用于存储名称
      isExpanded: false, // 控制展开/收起的状态
    };
  },
  methods: {
    handleSearch() {
      console.log("查询编码:", this.search1);
      console.log("查询名称:", this.search2);
    },
    handleReset() {
      this.search1 = "";
      this.search2 = "";
    },
    toggleExpand() {
      this.isExpanded = !this.isExpanded; // 切换展开状态
    },
  },
};
</script>

<style scoped>
.search-bar {
  height: 100%;
  margin: 0;
  padding: 8px 24px;
  color: rgba(0, 0, 0, 0.65);
  font-size: 14px;
  list-style: none;
  background-color: #fff;
  transition: all 0.3s;
  border-radius: 2px;
}

.select-bar {
  display: flex;
  align-items: center;
}

.select-item {
  display: flex;
  align-items: center;
  padding: 0 12px;
  width: 384px;
}

label {
  width: 49px;
  color: #000;
  margin-right: 8px;
}

.input-field {
  width: 335px;
  height: 22px;
  padding: 4px 11px;
  border-radius: 5px;
  border: 1px solid #d9d9d9;
  transition: border-color 0.3s; /* 边框颜色变化过渡 */
  outline: none; /* 移除默认轮廓 */
}

/* 输入框鼠标悬停效果 */
.input-field:hover {
  border-color: #409eff; /* 悬停时边框颜色 */
}

/* 输入框获得焦点时的样式 */
.input-field:focus {
  border-color: #409eff; /* 焦点时边框颜色 */
  box-shadow: 0 0 5px rgba(64, 158, 255, 0.5); /* 焦点时阴影 */
}

/* 按钮样式 */
.search-button,
.reset-button,
.toggle-button {
  padding: 10px 15px; /* 内边距 */
  border-radius: 4px; /* 圆角 */
  transition: background-color 0.3s; /* 背景颜色变化过渡 */
}

/* 查询按钮 */
.search-button {
  background-color: #409eff; /* 主色调 */
  color: white; /* 字体颜色 */
  border: 1px solid #409eff;
  width: 82px;
  height: 32px;
  line-height: 12px;
}

/* 查询按钮悬停效果 */
.search-button:hover {
  background-color: #66b1ff; /* 悬停时背景色 */
  border-color: #66b1ff;
}

/* 重置按钮 */
.reset-button {
  background-color: #fff; /* 重置按钮背景 */
  color: rgba(0, 0, 0, 0.65); /* 字体颜色 */
  border: 1px solid #d9d9d9;
  width: 82px;
  height: 32px;
  line-height: 12px;
  margin-left: 8px;
  padding: 0 15px;
  transition: all 0.3s;
}

/* 重置按钮悬停效果 */
.reset-button:hover {
  background-color: #e6f7ff; /* 悬停时背景色 */
  border-color: #409eff;
  color: #409eff;
}

/* 图标样式 */
.search-button i,
.reset-button i,
.toggle-button i {
  margin-right: 5px; /* 图标与文本之间的间距 */
}
.toggle-button {
  border: none;
  background-color: #fff;
  color: #409eff;
}
/* 展开内容的样式 */
.expand-content {
  margin-top: 10px; /* 与按钮之间的间距 */
  padding: 10px;
  border: 1px solid #d9d9d9; /* 边框 */
  border-radius: 4px; /* 圆角 */
  background-color: #f9f9f9; /* 背景颜色 */
}
</style>
